/**
 * knowledge-graph store
 * @author Tao Zhang
 */
/* eslint-disable */
import Vue from 'vue'
import {
  Module,
  Mutation,
  VuexModule,
  getModule,
  Action,
} from 'vuex-module-decorators'
import store from '@/store'
import {
  queryPanelInfoByVid,
  plotLayerByGeoJsonApi,
  searchAdministrativeApi,
  dashboardUpdateApi,
  queryKGDashBoardApi,
  updateGisInfoApi,
} from '@/api/knowledge-graph'
import { bindChartData, buildSaveParameters } from '@/util/common'
import { parseChartOptionToFunction } from '@/components/common/VisualizationDashboard/util'
import { saveWidget, updateWidget } from '@/api/widget'
import { cloneDeep } from 'lodash'
import { DashboardInfo, GisInfo } from '@/interface/k-graph-interface'
import { shapePrefixInfo } from '@/util/prefix-utils'

// 图层数据
export interface LayerData {
  datajson: any
  geojson: any
  type: string
}

// 图层数据 map
export interface LayersData {
  [key: number]: LayerData
}

//  可视化侧选中的实体节点信息
export interface EntityInfo {
  id: string
  attrs: any
}

//  可视化侧选中的实体节点信息
export interface GridList {
  id: number //  entity id
  list: any
}

@Module({ dynamic: true, namespaced: true, name: 'KGraphStore', store })
class KGraphStore extends VuexModule {
  private _projectId: any = null // 项目id
  // KGraph collapsed 状态 (图谱可视化 & 图谱系统构建)
  private _graphVisCollapsed: boolean = false
  private _graphSysCollapsed: boolean = false
  // 地图各类 loading 状态
  public _mapLoading: boolean = false
  private _currentMapConfig: any = null // 当前地图配置， 用来作为切换对比
  // 图层数据 id: geoJson
  private _layerData: LayersData = {} // 图层渲染数据
  private _mapboxInstance: any = null // mapbox 实例

  public knowledgeGraphMode: string = 'edit-copy' // edit- 编辑态，preview - 预览态, publish - 发布态
  public currentGridItem: any | null = null //  当前编辑的chart
  public gridList: Array<GridList> = [] //  打开面板的chart 集合

  public _simpleMapLoading: boolean = false //  简易封装的gisMap loading 情况
  private _simpleLayerData: LayersData = {} // 图层渲染数据

  public selectEntityPanel: number = 0 //  选中的实体面板
  public _entityPanelList: any[] = [] //  打开的实体面板集合

  public _selectedEntityNode: EntityInfo | null = null //  可视化侧选中的实体信息

  public dashboardId: number = 0 //  知识图谱画布id
  public entityPanelRightPos: number = 0 //  系统默认的右偏移距离；如果连续打开的情况，则出现在左侧
  public fixedLayerId: number[] = [] //  设置常驻的layerId
  //  筛选器相关 start
  public checkedClassKeys: string[] = [] //  勾选的class options
  public checkedRelationKeys: string[] = [] //  勾选的relation options
  public filterRawData: any = {}

  public graphId: number = -1
  public searchInput: string = ''
  public reloadGraph: any | null = null
  //  for publish temparory save filters
  public dynamicFilters: any = null

  //  for publish Number SAVE
  public publishNo: string = ''

  public sysSetting: any = {
    nameSet: 'abbr',
    interactGraph: true,
  }
  //  'entity' / 'sys'  聚焦实体面板 / 系统的小弹窗【搜索框等】
  public focusBox: string = ''
  private _lock: boolean | null = null // 项目是否锁定
  // 由/KGraph/queryByProjectId接口返回的全量图谱信息
  public _sourceData: any = null
  // 每一份知识图谱都有一个唯一的uri前缀
  public _baseUri: string = ''

  @Mutation
  public setBaseUri(data: any) {
    this._baseUri = data
  }

  public get baseUri() {
    return this._baseUri
  }

  @Mutation
  public setSourceData(data: any) {
    this._sourceData = data
  }

  public get sourceData() {
    return this._sourceData
  }
  // 项目是否锁定
  public get getLock() {
    return this._lock
  }
  //  用户权限 - 访客，开发者， 管理员，拥有者
  public _userRoleId: any = null

  public get userRoleId() {
    return this._userRoleId
  }

  public get isProjectGuest() {
    return this._userRoleId === 4
  }

  public get isProjectDeveloper() {
    return this._userRoleId === 3
  }

  public get isProjectManager() {
    return this._userRoleId?.id === 2
  }

  public get isProjectOwner() {
    return this._userRoleId?.id === 1
  }

  private _currentUserId: number = 0

  public get getUserId() {
    return this._currentUserId
  }

  @Mutation
  public setUserRoleId(data: any) {
    this._userRoleId = data
  }

  @Mutation
  public setUserId(id: number) {
    this._currentUserId = id
  }

  @Mutation
  public setLock(lock: boolean) {
    this._lock = lock
  }

  @Mutation
  public setFocusBoxg(data: any) {
    this.focusBox = data
  }

  @Mutation
  public setSysSetting(data: any) {
    this.sysSetting = data
  }

  @Mutation
  public setNameSetting(value: string) {
    this.sysSetting['nameSet'] = value
  }

  @Mutation
  public setInteractSetting(value: boolean) {
    this.sysSetting['interactGraph'] = value
  }

  @Mutation
  public setPublishNo(data: string) {
    this.publishNo = data
  }

  @Mutation
  public setDynamicFilters(data: any) {
    this.dynamicFilters = data
  }

  @Mutation
  public setReloadGraph(data: any) {
    this.reloadGraph = data
  }

  @Mutation
  public setSearchInput(text: string) {
    this.searchInput = text
  }

  @Mutation
  public setGraphId(id: number) {
    this.graphId = id
  }

  @Mutation
  public setClassKeys(checkedKeys: any) {
    this.checkedClassKeys = checkedKeys
  }

  @Mutation
  public setRelationKeys(checkedKeys: any) {
    this.checkedRelationKeys = checkedKeys
  }

  @Mutation
  public setFilterRawData(rawData: any) {
    this.filterRawData = rawData
  }

  // 更新 可视化graph 时间戳
  private _updateVisGraphTime: number | null = null
  public get updateVisGraphTime(): number | null {
    return this._updateVisGraphTime
  }

  @Mutation
  public setUpdateVisGraphTime(): void {
    this._updateVisGraphTime = new Date().getTime()
  }

  @Mutation
  public emptyFixedLayerId() {
    this.fixedLayerId = []
  }

  @Mutation
  public addFixedLayerId(layerId: number) {
    this.fixedLayerId.push(layerId)
  }

  @Mutation
  public deleteFixedLayerId(layerId: number) {
    const index = this.fixedLayerId.findIndex((id) => id === layerId)
    this.fixedLayerId.splice(index, 1)
  }

  // dashboard text
  public get textList() {
    return this._dashboardInfo?.text || null
  }

  @Mutation
  public addDashboardText(data: any) {
    if (this._dashboardInfo) {
      this._dashboardInfo.text.push(data)
    }
  }

  @Mutation
  public setDashboardText(data: any) {
    if (this._dashboardInfo) {
      const index = this._dashboardInfo.text.findIndex((item: any) => {
        return data.i === item.i
      })
      this._dashboardInfo.text.splice(index, 1, data)
    }
  }

  @Mutation
  public deleteTextItem(data: any) {
    if (this._dashboardInfo) {
      const index = this._dashboardInfo.text.findIndex((item: any) => {
        return data.i === item.i
      })
      this._dashboardInfo.text.splice(index, 1)
    }
  }

  public get projectId() {
    return this._projectId
  }
  @Mutation
  public setProjectId(projectId: any) {
    this._projectId = projectId
  }
  public get entityPanelList() {
    return this._entityPanelList
  }

  public get selectedEntityNode() {
    return this._selectedEntityNode
  }

  // 点击的图层 要素 信息
  public _clickLayerFeatureInfo: any[] | null = null

  public get clickLayerFeatureInfo() {
    return this._clickLayerFeatureInfo
  }
  @Mutation
  public setClickLayerFeatureInfo(features: any) {
    this._clickLayerFeatureInfo = cloneDeep(features)
  }

  @Mutation
  public setSelectedEntityNode(entity: EntityInfo | null) {
    this._selectedEntityNode = cloneDeep(entity)
  }

  /**
   * 获取 图层数据
   * @param parameters
   * @param isPublish - 是否在publish view请求
   */
  @Action
  public async queryEntityInfo(parameters: any) {
    const response: any = await queryPanelInfoByVid({ params: parameters })
    const { code, data } = response.data
    const shapeData = shapePrefixInfo(data, this.baseUri)
    if (code === 200) {
      shapeData?.items?.forEach((item: any) => {
        // 后端把图片数据的type也给弄成了type
        item.children?.forEach((child: any) => {
          if (
            child.type === 'text' &&
            child.attrValue.includes('data:image/')
          ) {
            child.type = 'img'
          }
        })
      })
      const { id, ...rest } = shapeData
      const entityData: any = {
        id,
        //  在发布态，需要从publishLayout 拿 layout 信息
        // layout: parameters.publish
        //   ? response.data.result.publishLayout
        //   : response.data.result.layout,
        // basic,
        ...rest,
      } //  store layout & basic for update case
      this.context.commit('addEntityPanelList', entityData)
    }
    return response
  }

  @Mutation
  public setEntityPanelList(data: any) {
    //  重置实体panel，仅一个
    this._entityPanelList = data
  }

  @Mutation
  public addEntityPanelList(data: any) {
    //  实体列表中添加
    this._entityPanelList.push(data)
  }

  @Mutation
  public replaceEntityPanelList(data: any) {
    const index = this._entityPanelList.findIndex(
      (item: any) => item.id === data.id
    )
    Vue.set(this._entityPanelList, index, data)
  }

  //  关闭并保存实体面板
  @Mutation
  public async removeEntityPanelList(entityData: any) {
    const entityId = entityData.id
    const index = this._entityPanelList.findIndex(
      (item: any) => item.id === entityId
    )
    this._entityPanelList.splice(index, 1)
  }

  @Mutation
  public setSelectEntityPanel(id: number) {
    this.selectEntityPanel = id
  }

  @Mutation
  public setDashboardId(id: number) {
    this.dashboardId = id
  }

  @Mutation
  public setEntityPanelRightPos(right: number) {
    this.entityPanelRightPos = right
  }

  @Mutation
  public setGridList(data: any) {
    this.gridList = data
  }

  @Mutation
  public addGridList(data: GridList) {
    this.gridList.push(data)
  }

  @Mutation
  public removeGridList(entityId: number) {
    const index = this.gridList.findIndex((item: any) => item.id === entityId)
    this.gridList.splice(index, 1)
  }

  @Mutation
  public updateGridListItem(gridItem: any) {
    const position = this.gridList.findIndex(
      (item: any) => item.id === gridItem.entityId
    )

    const indexSet = this.gridList[position].list.findIndex((dataItem: any) => {
      return dataItem._id_ === gridItem._id_
    })
    if (indexSet >= 0) {
      Vue.set(this.gridList[position].list, indexSet, gridItem)
    }
  }

  /**
   * 更新widget
   * @param gridItem
   */
  @Mutation
  public updateWidget(parameterSet: {
    gridItem: any
    // index: number
    onSuccess?: Function
    onError?: Function
    syncUpdate?: boolean
    onlyLocal?: boolean
  }) {
    const { gridItem, onSuccess, onError } = parameterSet
    /** 只在画布上保存无需走一遍接口 */
    //  if (parameterSet.onlyLocal) {
    //    this.gridList[parameterSet.index].i === gridItem.i &&
    //      Vue.set(this.gridList, index, gridItem)
    //    return
    //  }
    const parameters = buildSaveParameters(gridItem)
    const apiFetch = gridItem.widgetId ? updateWidget : saveWidget
    gridItem.isLoading = true
    parameters.data.tid = undefined
    apiFetch(parameters)
      .then((response: any) => {
        gridItem.isLoading = false
        if (response.data.code === 100 && !gridItem.widgetId) {
          gridItem.widgetId = response.data.result
        }
        const position = this.gridList.findIndex(
          (item: any) => item.id === gridItem.entityId
        )

        const indexSet = this.gridList[position].list.findIndex(
          (dataItem: any) => {
            return dataItem._id_ === gridItem._id_
          }
        )
        if (indexSet >= 0) {
          Vue.set(this.gridList[position].list, indexSet, gridItem)
          if (
            this.currentGridItem?._id_ === gridItem._id_ &&
            parameterSet.syncUpdate
          ) {
            this.currentGridItem = gridItem
          }
          console.log('updateWidget after gridItem:', gridItem)
        }
        /** 加载成功回调 */
        onSuccess && onSuccess(gridItem)
        onError && onError(gridItem)
        if (parameterSet.syncUpdate) {
          Vue.set(this.gridList[position].list, indexSet, gridItem)
        }
        // Vue.set(this.gridList, index, gridItem)
      })
      .catch(() => {
        gridItem.isLoading = false
        //  if (this.visualizationInstance) {
        //    this.visualizationInstance.$message.error('widget信息同步失败')
        //  }
      })
  }

  /**
   * 为gridItem 绑定数据
   * @param query 查询参数
   * @param data 数据
   */
  @Mutation
  public gridItemBindData(
    data: any,
    gridItemSet?: any,
    keepCurrentGridItem?: boolean
  ) {
    const gridItem = bindChartData(gridItemSet || this.currentGridItem, data)
    if (gridItem && gridItem.chartOptions) {
      const dom = (document as any).body.querySelector(
        `#grid-item-${gridItem._id_}`
      )
      if (dom) {
        Vue.set(gridItem.chartOptions, 'size', [
          dom.offsetWidth,
          dom.offsetHeight,
        ])
      }
      Vue.set(gridItem, 'chartType', cloneDeep(gridItem.chartType))
    }
    const position = this.gridList.findIndex(
      (item: any) => item.id === data.entityId
    )

    this.gridList[position].list.forEach((dataItem: any, index: number) => {
      if (gridItem && dataItem._id_ === gridItem._id_) {
        const parameters = buildSaveParameters(gridItem)
        //  if (!gridItem.widgetId && this.savingMaps[gridItem.i]) {
        //    return
        //  }
        //  if (this.currentDashboard.id) {
        //    parameters.data.dashboardId = this.currentDashboard.id
        //  }
        parameters.data.tid = undefined
        const apiFetch = gridItem.widgetId ? updateWidget : saveWidget
        //  this.savingMaps[gridItem.i] = true
        apiFetch(parameters)
          .then((response: any) => {
            //  this.savingMaps[gridItem.i] = false
            if (response.data.code === 100 && !gridItem.widgetId) {
              gridItem.widgetId = response.data.result
            }
            Vue.set(this.gridList[position].list, index, gridItem)
            parseChartOptionToFunction(gridItem.chartOptions)
            // 某些情况下无需设置当前gridItem，例如filterForm任务触发
            if (!keepCurrentGridItem) {
              this.currentGridItem = gridItem
            }
          })
          .catch(() => {
            //  this.savingMaps[gridItem.i] = false
            //  if (this.visualizationInstance) {
            //    this.visualizationInstance.$message.error('widget信息同步失败')
            //  }
          })
      }
    })
  }

  /**
   * 设置当前需要配置的chart
   * @param data
   */
  @Mutation
  public setCurrentGridItem(data: any | null): void {
    // const tag = data && this.currentGridItem?.i === data?.i

    this.currentGridItem = data
    // if (!tag) {
    //   this.recommendBaseSpec = null
    // }
  }

  //  更新 gisMap 时间戳
  private _updateGisMapTime: number | null = null
  public get updateGisMapTime(): number | null {
    return this._updateGisMapTime
  }
  @Mutation
  public setUpdateGisMapTime(): void {
    this._updateGisMapTime = new Date().getTime()
  }

  // 更新 dashboard 时间戳
  private _updateDashboardTime: number | null = null
  private _clearDashboardTime: number | null = null
  public get updateDashboardTime(): number | null {
    return this._updateDashboardTime
  }
  public get clearDashboardTime(): number | null {
    return this._clearDashboardTime
  }
  @Mutation
  public setUpdateDashboardTime(): void {
    this._updateDashboardTime = new Date().getTime()
  }
  @Mutation
  public setClearDashboardTime(): void {
    this._clearDashboardTime = new Date().getTime()
  }
  //  当前实体列表
  private _entityLayer: Array<any> = []
  public get entityLayer(): Array<any> {
    return this._entityLayer
  }

  // 当前 dashboard 信息， 包含有图层列表，图层信息， 文本信息
  private _dashboardInfo: DashboardInfo | any = null
  // 整体 dashboard 信息
  public get dashboardInfo(): DashboardInfo | null {
    return this._dashboardInfo
  }
  // 所有图层数据
  public get allLayerList(): Array<any> {
    return this.dashboardInfo?.layerData || []
  }
  // 图层列表, (过滤没有常驻的图层)
  public get layerList() {
    const showLayer: any[] = this._dashboardInfo?.layerData.filter(
      (layer: any) => {
        // return !Object.keys(layer).includes('fixed') || !!layer.fixed
        // return !Object.keys(layer).includes('fixed')
        // 后端layer统一数据结构，所有的layer都包括fixed属性，之前没有fixed属性的，均赋值为fixed:false
        return !layer.fixed
      }
    )
    return showLayer
  }
  // dashboard gisInfo
  public get gisInfo(): GisInfo | null {
    return this._dashboardInfo?.gisInfo || null
  }
  // 虚拟的 tabId
  public get featureLayerIds(): string[] {
    return (
      this._dashboardInfo?.layerData
        .filter((layer: any) => layer.visible === 1)
        .map((layer: any) => String(layer.id)) || []
    )
  }
  @Mutation
  public setDashboardInfo(info: DashboardInfo | null) {
    this._dashboardInfo = info
  }
  @Mutation
  public setDashboardGisInfo({ key, value }: any) {
    if (this._dashboardInfo) {
      this._dashboardInfo.gisInfo[key] = value
    }
  }
  // 修改图层为常驻图层
  @Mutation
  public setDashboardLayerFixed({ id, fixed }: any) {
    if (this._dashboardInfo) {
      this._dashboardInfo.layerData.forEach((layer: any) => {
        if (layer.id === id) {
          layer.fixed = fixed
        }
      })
    }
  }

  @Mutation
  public setEntityLayer(layerList: Array<any>) {
    this._entityLayer = layerList
  }

  /**
   * 修改图层顺序
   * @param order
   */
  @Mutation
  public editLayerOrder(order: any) {
    this._dashboardInfo?.layerData.forEach((layer: any) => {
      layer.order = order[layer.id]
    })
  }

  /**
   * 修改图层显隐
   * @param editVisible
   */
  @Mutation
  public editLayerVisible(editVisible: { [layerId: string]: number }) {
    this._dashboardInfo?.layerData.forEach((layer: any) => {
      if (Object.keys(editVisible).includes(String(layer.id))) {
        layer.visible = editVisible[layer.id]
      }
    })
  }

  /**
   * 获取 dashboard 信息
   * @param parameters
   */
  @Action
  public async queryKGDashBoard(parameters: any) {
    const response: any = await queryKGDashBoardApi({ params: parameters })
    const { code, data } = response.data
    const shapeData = shapePrefixInfo(data, this.baseUri)
    if (code === 200) {
      // 后端用字符串拼接的geometry，需要前端转为json的格式
      shapeData.layerData.forEach((layer: any) => {
        layer.geojson.features.forEach((feature: any) => {
          feature.geometry =
            typeof feature.geometry === 'string'
              ? JSON.parse(feature.geometry)
              : feature.geometry
        })
      })
      const dashboardInfo: any = {
        layerData: shapeData.layerData,
        gisInfo: shapeData.gisInfo,
        sysSetting: shapeData.sysSetting,
      }
      this.context.commit('setDashboardInfo', dashboardInfo)

      //  set entity layer - 图层管理中 实体列表
      this.context.commit('setEntityLayer', shapeData.entityLayer)

      //  set dashboard id
      // 后端改造后已经没有dashboardId
      this.context.commit('setDashboardId', 123)

      if (shapeData?.sysSetting) {
        const sysSetting: any = shapeData.sysSetting
        this.context.commit('setSysSetting', sysSetting)
      }
    }
    return response
  }

  /**
   * 获取 dashboard 信息
   * @param parameters
   */
  @Action
  public async setKGDashBoard(response: any) {
    // if (response.data.code === 100) {
    const dashboardInfo: any = response.layout
    this.context.commit('setDashboardInfo', dashboardInfo)

    //  set entity layer - 图层管理中 实体列表【publish 无返回】
    // const entityLayer: any = response.entityLayer
    // this.context.commit('setEntityLayer', entityLayer)

    //  set dashboard id
    this.context.commit('setDashboardId', response.id)
    // }
    return response
  }

  /**
   * 更新 dashboard 信息
   */
  @Action
  public async updateDashboard() {
    const result = {
      ...this._dashboardInfo,
      sysSetting: {
        ...this.sysSetting,
      },
    }
    const parameters: { [key: string]: any } = {
      layout: JSON.stringify(result),
      projectId: this.projectId,
      id: this.dashboardId,
    }
    const response: any = await dashboardUpdateApi({ data: parameters })
    return response
  }

  @Action
  public async updateGisInfo() {
    const formData = new FormData()
    const layout = {
      gisInfo: {
        ...this.gisInfo,
      },
      sysSetting: {
        ...this.sysSetting,
      },
      entityLayer: [],
      layerData: [],
    }
    formData.append('knowledgeGraphFileId', this.graphId.toString())
    formData.append('layout', JSON.stringify(layout))
    const response: any = await updateGisInfoApi({ data: formData })
    return response
  }

  @Mutation
  public changeVisualizationMode(mode: string) {
    this.knowledgeGraphMode = mode
  }

  /**
   * ToolBar
   */
  private _currentToolBarAction: any = null // 当前激活的 工具栏
  public get currentToolBarAction() {
    return this._currentToolBarAction
  }
  @Mutation
  public setCurrentToolBarAction(action: any) {
    this._currentToolBarAction = action
  }

  public get layerData() {
    return this._layerData
  }

  public get simpleLayerData() {
    return this._simpleLayerData
  }

  public get mapLoading() {
    return this._mapLoading
  }

  public get simpleMapLoading() {
    return this._simpleMapLoading
  }

  public get currentMapConfig() {
    return this._currentMapConfig
  }
  public get graphVisCollapsed() {
    return this._graphVisCollapsed
  }
  public get graphSysCollapsed() {
    return this._graphSysCollapsed
  }
  public get mapboxInstance() {
    return this._mapboxInstance
  }
  @Mutation
  public setLayerData(data: any) {
    this._layerData = data
  }

  @Mutation
  public setSimpleLayerData(data: any) {
    this._simpleLayerData = data
  }
  @Mutation
  public setMapboxInstance(mapBox: any) {
    this._mapboxInstance = mapBox
  }

  @Mutation
  public setMapLoading(loading: boolean) {
    this._mapLoading = loading
  }

  @Mutation
  public setSimpleMapLoading(loading: boolean) {
    this._simpleMapLoading = loading
  }

  @Mutation
  public setCurrentMapConfig(tab: any) {
    this._currentMapConfig = tab
  }

  @Mutation
  public setGraphVisCollapsed(collapsed: boolean) {
    this._graphVisCollapsed = collapsed
  }

  @Mutation
  public setGraphSysCollapsed(collapsed: boolean) {
    this._graphSysCollapsed = collapsed
  }

  /**
   * 清除数据
   */
  @Mutation
  public clearGisInfo() {
    // this._gisTabs = []
    this._layerData = {}
    // this._selectLayer = null
    // this._fullScreenState = false
    // this._layerPanelState = this._recordPanelAndToolStatus.layerPanelState
    // this._gisAnalysisToolState = this._recordPanelAndToolStatus.gisAnalysisToolState
    this._mapboxInstance.remove()
  }

  /**
   * 获取 图层数据
   * @param parameters
   */
  @Action
  public async queryLayerDataById(parameters: any) {
    const response: any = await plotLayerByGeoJsonApi({ data: parameters })
    if (response.data.code === 100) {
      const geoData: any = response.data.result
      this.context.commit('addLayerData', { [parameters.layerId]: geoData })
    }
    return response
  }

  /**
   * 获取 图层数据
   * @param parameters
   */
  @Action
  public async querySimpleLayerDataById(parameters: any) {
    const response: any = await plotLayerByGeoJsonApi({ data: parameters })
    if (response.data.code === 100) {
      const geoData: any = response.data.result
      this.context.commit('addSimpleLayerData', {
        [parameters.layerId]: geoData,
      })
    }
    return response
  }

  // 存储图层数据
  @Mutation
  public addSimpleLayerData(layerDataInfo: LayersData) {
    this._simpleLayerData = {
      ...this._simpleLayerData,
      ...layerDataInfo,
    }
  }

  // 存储图层数据
  @Mutation
  public addLayerData(layerDataInfo: LayersData) {
    this._layerData = {
      ...this._layerData,
      ...layerDataInfo,
    }
  }

  /**
   * 调用天地图搜索服务
   * @param parameters
   */
  @Action
  public async searchAdministrative(parameters: any) {
    const response: any = await searchAdministrativeApi({ params: parameters })
    return response
  }
}

export default getModule(KGraphStore)
